import 'package:flutter/material.dart';
import 'package:cook_dinner/config/include.dart';

class UserTopData extends StatelessWidget {
  const UserTopData({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: HYSizeFit.screenWidth,
      padding: EdgeInsets.only(top: 49.rpx - HYSizeFit.statusHeight),
      decoration: const BoxDecoration(
        gradient: RadialGradient(
          center: Alignment.topLeft,
          radius: 1, // 控制渐变的范围，1.0表示从中心点开始，更大的值会使渐变效果扩散更广
          colors: [
            Color(0xfffff7ef),
            Color(0xfffcfaf1),
            Color(0xfffcfaf1),
            Color(0xfffcfaf1),
            Colors.white,
          ],
        ),
      ),
      child: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: [
              InkWell(
                onTap: () => AppTo.goto(context, AppPage.chat),
                child: Image.asset(
                  'assets/images/chatm.png',
                  width: 30.2.rpx,
                  height: 29.8.rpx,
                ),
              ),
              SizedBox(width: 19.rpx),
              InkWell(
                onTap: () => AppTo.goto(context, AppPage.setting),
                child: Image.asset(
                  'assets/images/set.png',
                  width: 34.8.rpx,
                  height: 29.5.rpx,
                ),
              ),
            ],
          ),
          Padding(
            padding: EdgeInsets.only(
              left: 34.rpx,
              right: 50.rpx,
              top: 4.rpx,
            ),
            child: Row(
              children: [
                Image.asset(
                  'assets/images/uavart.png',
                  width: 75.rpx,
                  height: 75.rpx,
                ),
                SizedBox(width: 20.rpx),
                Expanded(
                  child: Row(
                    children: [
                      Expanded(
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Text(
                              'Stcherder',
                              style: TextStyle(
                                fontSize: 20.rpx,
                                color: const Color(0xff333333),
                              ),
                            ),
                            SizedBox(height: 6.rpx),
                            Text(
                              '来到做饭吧的第521天',
                              style: TextStyle(
                                fontSize: 14.rpx,
                                color: const Color(0xff999999),
                              ),
                            ),
                          ],
                        ),
                      ),
                      InkWell(
                        onTap: () => AppTo.goto(context, AppPage.caloric),
                        child: Image.asset(
                          'assets/images/gright.png',
                          width: 28.rpx,
                          height: 28.rpx,
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
          SizedBox(height: 19.rpx),
          Padding(
            padding: EdgeInsets.only(
              left: 31.rpx,
              right: 31.rpx,
              bottom: 15.rpx,
            ),
            child: Container(
              width: double.infinity,
              margin: EdgeInsets.only(top: 19.rpx),
              padding: EdgeInsets.only(bottom: 16.rpx),
              decoration: BoxDecoration(
                border: Border(
                  bottom: BorderSide(
                      color: const Color(0xffEBEBEB), width: 0.5.rpx),
                ),
              ),
              child: Row(
                children: [
                  Expanded(
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        _description('65', '粉丝'),
                        _description('23', '关注'),
                        _description('18', '作品'),
                      ],
                    ),
                  ),
                  SizedBox(width: 37.rpx),
                  Expanded(
                    child: Row(
                      children: [
                        InkWell(
                          onTap: () {
                            AppTo.goto(context, AppPage.selfSet);
                          },
                          child: Container(
                            width: 76.rpx,
                            height: 28.rpx,
                            alignment: Alignment.center,
                            decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(14.rpx),
                              color: Colors.white,
                            ),
                            child: Text(
                              '编辑资料',
                              style: TextStyle(
                                color: const Color(0xffFA8303),
                                fontSize: 14.rpx,
                              ),
                            ),
                          ),
                        ),
                        SizedBox(width: 18.rpx),
                        InkWell(
                          onTap: () => AppTo.goto(context, AppPage.signature),
                          child: Container(
                            width: 76.rpx,
                            height: 28.rpx,
                            decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(14.rpx),
                              color: Colors.white,
                            ),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                Image.asset(
                                  'assets/images/ast.png',
                                  width: 16.5.rpx,
                                  height: 16.5.rpx,
                                ),
                                SizedBox(width: 4.rpx),
                                Text(
                                  '签到',
                                  style: TextStyle(
                                    color: const Color(0xffFA8303),
                                    fontSize: 14.rpx,
                                  ),
                                ),
                              ],
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ),
          Padding(
            padding:
                EdgeInsets.only(bottom: 31.rpx, left: 33.rpx, right: 33.rpx),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                _cartBtn(img: 'cartp.png', t1: '购物车', t2: '4个商品'),
                _cartBtn(img: 'tips.png', t1: '厨艺提升', t2: '看教程学技术'),
                _cartBtn(img: 'ontime.png', t1: '浏览记录', t2: '看过的笔记'),
              ],
            ),
          ),
        ],
      ),
    );
  }

  Widget _description(nus, text) {
    return Column(
      children: [
        Text(
          nus,
          style: TextStyle(
            color: const Color(0xff000000),
            fontSize: 14.rpx,
          ),
        ),
        SizedBox(height: 6.rpx),
        Text(
          text,
          style: TextStyle(
            color: const Color(0xff000000),
            fontSize: 14.rpx,
          ),
        ),
      ],
    );
  }

  Widget _cartBtn({img, t1, t2}) {
    return Container(
      width: 108.rpx,
      height: 46.rpx,
      padding: EdgeInsets.only(left: 16.rpx, right: 10.rpx),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(6.rpx),
        boxShadow: [
          BoxShadow(
            offset: Offset(0, 2.rpx), // 垂直偏移4px，水平偏移0
            blurRadius: 4.rpx, // 模糊半径20px
            spreadRadius: 0.5.rpx, // 扩展半径0，保持阴影大小不变
            color: const Color(0xFF000000).withOpacity(0.08), // 颜色设置为透明度较低的黑色
          ),
        ],
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Image.asset(
                'assets/images/$img',
                width: 16.rpx,
                height: 16.rpx,
              ),
              SizedBox(width: 6.rpx),
              Text(
                t1 ?? '',
                style: TextStyle(
                  color: const Color(0xffFA8303),
                  fontSize: 14.rpx,
                ),
              ),
            ],
          ),
          Text(
            t2 ?? '',
            style: TextStyle(
              color: const Color(0xffFA8303).withOpacity(0.6),
              fontSize: 8.rpx,
            ),
          ),
        ],
      ),
    );
  }
}
